package cn.snailhd.util;

import java.util.Random;
import java.util.UUID;

public class StringUtils {
	


	public static String randomCode(int len,String str){
		int strlen = str.length();
		StringBuilder pwd = new StringBuilder();
		for(int i=0;i<len;i++){
			Random random = new Random();
			int index = random.nextInt(strlen);
			pwd.append(str.charAt(index));			
		}
		return pwd.toString();
	}
	
	

	public static String randomCode(int len){
		String str="123456789abcdefghijklmnopqrstuvwxyz";
		return randomCode(len,str);
	}
	
	/**
	 * 生成32位无符号小写随机码
	 * @return
	 */
	public static String guid(){
		UUID u = UUID.randomUUID();
		String guid =u.toString().toLowerCase().replaceAll("-", "");
		return guid;
	}
	
	public static void main(String[] args) {
		System.out.println(guid());
	}
	
	
	/**
	 * 判断是否为null,""," "
	 * @param s
	 * @return
	 */
	public static boolean isBlank(String s) {
		if(s == null) {
			return true;
		}
		if(s.trim().isEmpty()) {
			return true;
		}
		return false;

	}
	
	/**
	 * 判断是否为null,""," "
	 * @param s
	 * @return
	 */
	public static boolean isNotBlank(String s) {
		if(s == null) {
			return false;
		}
		if(s.trim().isEmpty()) {
			return false;
		}
		return true; 
	}
	
}
